{% extends "base.html" %}
{# Copyright The IETF Trust 2021, All Rights Reserved #}
{% load origin django_bootstrap5 %}
{% block morecss %}img.logo {max-width: 30rem; max-height: 30rem;}{% endblock %}
{% block title %}Edit Hosts for {{ meeting }} Proceedings{% endblock %}
{% block content %}
    {% origin %}
    <h1>
        Edit Meeting Hosts
        <br>
        <small class="text-body-secondary">{{ meeting }}</small>
    </h1>
    {% if meeting.proceedings_final %}
        <div class="alert alert-warning my-3">The proceedings for this meeting have already been finalized.</div>
    {% endif %}
    <p class="alert alert-info my-3">
        The entries below will appear on the proceedings as meeting hosts.
        If you need to add more than there are slots, fill out the form below, save, and
        reopen this page.
    </p>
    <form method="post" enctype="multipart/form-data">
        {% csrf_token %}
        {{ formset.management_form }}
        {{ formset.non_form_errors }}
        <table class="table table-striped">
            <tbody>
            {% for form in formset %}
                <tr class="row">
                    <td class="col-md-3">
                        {% if form.instance.pk and form.instance.logo %}
                            <img class="logo w-100 img-fluid img-thumbnail"
                                 alt="Meeting Host Logo"
                                 src="{% url 'ietf.meeting.views_proceedings.meetinghost_logo' num=meeting.number host_id=form.instance.pk %}">
                        {% else %}
                            (No logo)
                        {% endif %}
                    </td>
                    <td class="col-md-9">{% bootstrap_form form %}</td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
        <a class="btn btn-secondary float-end"
           href="{% url 'ietf.meeting.views.materials' num=meeting.number %}">Back</a>
        <button class="btn btn-primary" type="submit">Save</button>
    </form>
{% endblock %}